package com.serializetool;

import java.io.Serializable;
import java.util.Objects;

public class Response implements Serializable {
    /**
     * 任务Id
     */
    private long taskId;
    /**
     * 返回对象全类名
     */
    private Object result;
    /**
     * 异常返回
     */
    private Throwable errorMsg;

    private String magicNum;

    public Object getResult() {
        return result;
    }

    public void setResult(Object result) {
        this.result = result;
    }

    public Throwable getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(Throwable errorMsg) {
        this.errorMsg = errorMsg;
    }

    public Object getLastResult(){
        return getErrorMsg()==null?getResult():getErrorMsg();
    }

    public long getTaskId() {
        return taskId;
    }

    public void setTaskId(long taskId) {
        this.taskId = taskId;
    }

    public String getMagicNum() {
        return magicNum;
    }

    public void setMagicNum(String magicNum) {
        this.magicNum = magicNum;
    }

    @Override
    public String toString() {
        return "Response{" +
                "taskId=" + taskId +
                ", result=" + result +
                ", errorMsg=" + errorMsg +
                ", magicNum='" + magicNum + '\'' +
                '}';
    }
}
